{extend name="property/public/insidePageBase" /}
{block name="title"}用户详情{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form  layui-form-pane">
            <div class="layui-tab-item layui-show">
                <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                    <div class="layui-tab layui-tab-brief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">基本信息</li>
                            <li>操作日志</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <!--基本信息 add-->
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">用户姓名</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="username" value="{$info['username']??''}" disabled lay-verify="require" autocomplete="off" placeholder="请输入用户姓名" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">手机号码</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="mobile" value="{$info['mobile']??''}" disabled lay-verify="require" autocomplete="off" placeholder="请输入手机号" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">创建时间</label>
                                        <div class="layui-input-inline">
                                            <input type="text"  value="{$info['add_time'] ?? ''}" disabled autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">登录账号</label>
                                        <div class="layui-input-block">
                                            <input type="text"  value="{$info['account'] ?? ''}" disabled autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">所属部门</label>
                                        <div class="layui-input-inline">
                                            <input type="text"  value="{$info['full_group_name'] ?? ''}" disabled autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">邮箱账号</label>
                                        <div class="layui-input-inline">
                                            <input type="text"  value="{$info['email'] ?? ''}" disabled autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>
                                <!--基本信息 end-->

                                <!--角色列表 add-->
                                <script type="text/html" id="toolpropertyUserRole">
                                    <div class="layui-btn-container">
                                        {if $addUserRoleAuth}<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>{/if}
                                        {if $delUserRoleAuth}<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>{/if}
                                    </div>
                                </script>
                                <table class="layui-hide" id="propertyUserRoleList" lay-filter="propertyUserRoleList"></table>
                                <script type="text/html" id="tablepropertyUserRoleBar">
                                    <div class="layui-btn-group">
                                        {if $editUserRoleAuth} <a class="layui-btn layui-btn-sm  layui-btn-normal" lay-event="edit">编辑</a>{/if}
                                        {if $delUserRoleAuth}<a class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除</a>{/if}
                                    </div>
                                </script>
                                <!--角色列表 end-->
                            </div>
                            <div class="layui-tab-item">
                                <iframe id="valveIframe" src="{:url('propertyUsersLogList')}?user_id={$info['user_id']}" style="width: 100%;height: 100%;border:none;"></iframe>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
{__block__}
<script>
    // 获取屏幕的高度
    var screenHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    // 将屏幕的高度赋值给div
    document.getElementById("valveIframe").style.height = (screenHeight-100) + "px";

    layui.use(['laydate','table','upload'], function () {
        var laydate = layui.laydate, table = layui.table,upload = layui.upload;
        let propertyUId = {$info['id']};
        // 角色列表 add
        var tableIdpropertyUserRole = 'propertyUserRoleList';
        table.render({
            elem: '#'+tableIdpropertyUserRole,
            id:tableIdpropertyUserRole,
            url: '{:url("propertyUsersRoleList")}?property_uid='+propertyUId,
            toolbar: '#toolpropertyUserRole',
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'property_name', width: 158, title: '物业名称', sort: true},
                {field: 'role_name', width: 158, title: '角色名称', sort: true},
                {field: 'remark', minWidth: 120, title: '备注说明', sort: true},
                {field: 'edit_time', width: 160, title: '更新时间', sort: true}
                {if $editUserRoleAuth  || $delUserRoleAuth}
                , {title: '操作', width: 128, toolbar: '#tablepropertyUserRoleBar', align: "left"}
                {/if}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            height: 'full-220'
        });

        table.on('toolbar('+tableIdpropertyUserRole+')', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var url = '{:url("propertyUsersRoleAdd")}?property_uid='+propertyUId;
                var index = layer.open({
                    title: '添加角色',  type: 2, shade: 0.2, maxmin:true,area: ['500px', '400px'], content: url , btnAlign: 'c' , btn: ['确定', '取消'], yes: function (index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                        iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                            var field = data.field; //获取提交的字段
                            var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                            $.post(url, field, function (res) {
                                layer.close(loadAdd);
                                if (res.code === 0) {
                                    table.reload(tableIdpropertyUserRole); //数据刷新
                                    layer.close(index); //关闭弹层
                                    layer.msg(res.msg, {icon: 6, offset: '15px'});
                                } else {
                                    layer.msg(res.msg, {icon: 5, offset: '15px'});
                                }
                            });
                        });
                        submit.trigger('click');
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus(obj.config.id),data = checkStatus.data;
                var data = checkStatus.data, id = [];
                for (elem in data) {
                    id.push(data[elem].id);
                }
                if (id.length === 0) {
                    return layer.msg('请选择要删除的数据');
                }
                var url = '{:url("propertyUsersRoleDel")}';
                layer.confirm('删除后不可恢复！  是否确认? ', {icon: 3}, function () {
                    var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                    $.post(url, {ids: id}, function (res) {
                        layer.close(loadAdd);
                        if (res.code === 0) {
                            table.reload(tableIdpropertyUserRole); //数据刷新
                            layer.msg(res.msg, {icon: 6, offset: '15px'});
                        } else {
                            layer.msg(res.msg, {icon: 5, offset: '15px'});
                        }
                    });
                });
            }
        });

        table.on('tool('+tableIdpropertyUserRole+')', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                var url = '{:url("propertyUsersRoleEdit")}?id='+data.id;
                var index = layer.open({
                    title:'编辑 '+ data.role_name + ' 角色备注', type: 2,  shade: 0.2, maxmin:true, area: ['500px', '300px'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                        iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                            var field = data.field; //获取提交的字段
                            var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                            $.post(url, field, function (res) {
                                layer.close(loadAdd);
                                if (res.code === 0) {
                                    table.reload(tableIdpropertyUserRole); //数据刷新
                                    layer.close(index); //关闭弹层
                                    layer.msg(res.msg, {icon: 6, offset: '15px'});
                                } else {
                                    layer.msg(res.msg, {icon: 5, offset: '15px'});
                                }
                            });
                        });
                        submit.trigger('click');
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                var url = '{:url("propertyUsersRoleDel")}';
                layer.confirm('删除后不可恢复！  是否确认? ', {icon: 3}, function () {
                    var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                    $.post(url, {ids: [data.id]}, function (res) {
                        layer.close(loadAdd);
                        if (res.code === 0) {
                            table.reload(tableIdpropertyUserRole); //数据刷新
                            layer.msg(res.msg, {icon: 6, offset: '15px'});
                        } else {
                            layer.msg(res.msg, {icon: 5, offset: '15px'});
                        }
                    });
                });
            }
        });

    });
</script>
{/block}